<template>
  <div class="ke">
    <!-- <div class="powertop">
      <router-link class="powertopli powertopact" to="/yongjinzhichu/zhichuguanli"  v-if="checkquanxian('V0201').length > 0">支出订单管理</router-link>
      <router-link class="powertopli " to="/yongjinzhichu/yongjinzhichu"  v-if="checkquanxian('V0202').length > 0">佣金支出</router-link>
      <router-link class="powertopli " to="/yongjinzhichu/zhichudakuanshenhe" v-if="peizhi.second_commission_examine && checkquanxian('V0204').length > 0">支出审核</router-link>
      <router-link class="powertopli " to="/yongjinzhichu/zhichudakuan"  v-if="checkquanxian('V0203').length > 0">支出打款</router-link>

      <router-link class="powertopli" to="/yongjinzhichu/zhichupeizhi"  v-if="zhichupeizhi">支出配置</router-link>
      <router-link class="powertopli " to="/yongjinzhichu/yongjinzhichubaobiao" v-if="checkquanxian('V0205').length > 0">佣金支出报表</router-link>
    </div> -->
    <top2 @huoqupeizhi="huoqupeizhi"></top2>
    <div v-loading='loading' style="padding: 20px;">
      <div class="kflexc" style="margin-bottom: 20px;">


        <div style="width: 250px; margin-right: 20px; ">

          <el-select clearable v-model="all.merchant_name"  style="width: 250px;" filterable placeholder="选择分销商">
            <el-option :label="item.name" :value="item.child_shop_id"  v-for="item in fenxiaoshanglists" :key="item.child_shop_id" ></el-option>
          </el-select>
        </div>

        <div style="width: 250px; margin-right: 20px;">
          <el-input v-model="all.goods_name" placeholder="商品名称&编码"></el-input>
        </div>
        <div style="width: 250px; margin-right: 40px; position: relative;"  class="kflexc">

          <el-input v-model="all.order_id" placeholder="订单ID"></el-input>
          <el-tooltip class="item" effect="dark" content="批量查询" placement="top-start">
          	<span style="position: absolute; right: -30px; top: 8px; color: #1989FA; font-size: 16px; cursor: pointer;" @click="duoxuanlog = true">
          		<i class="el-icon-circle-plus"></i>
          	</span>
          </el-tooltip>

        </div>
        <div style="width: 250px; margin-right: 20px; ">
          <!-- <el-input v-model="all.cm_name" placeholder="客户经理"></el-input> -->
          <el-select  v-model="all.cm_name" style="width: 250px;" placeholder="选择客户经理" filterable clearable>
            <el-option :label="item.name" :value="item.id"  v-for="item in kehujinglilists" :key="item.id" ></el-option>
          </el-select>
        </div>
        <div style="width: 250px; margin-right: 20px; ">
          <el-select  v-model="all.change_type" style="width: 250px;" placeholder="是否修改过" filterable clearable>
            <el-option label="修改过结算状态" value="status"></el-option>
            <el-option label="修改过佣金金额" value="commission"></el-option>
          </el-select>
        </div>
      </div>
      <div class="kflexc" style="margin-bottom: 20px;">

        <div style="width: 250px; margin-right: 20px; ">
          <el-select  v-model="all.ok" style="width: 250px;" placeholder="是否满足结算" filterable clearable>
            <el-option label="否" value="0"></el-option>
            <el-option label="是" value="1"></el-option>
          </el-select>
        </div>
        <div style="width: 250px; margin-right: 20px; ">
          <el-select  v-model="all.is_settlement" style="width: 250px;" placeholder="是否可结算" filterable clearable>
            <el-option label="否" value="0"></el-option>
            <el-option label="是" value="1"></el-option>
          </el-select>
        </div>

        <div style="margin-right: 20px; font-size: 12px;">导入时间</div>
        <div style="margin-right: 20px;">
          <el-date-picker  v-model="times" @change="timeschange" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" :default-time="['00:00:00', '23:59:59']" range-separator="至"  start-placeholder="开始日期"  end-placeholder="结束日期"></el-date-picker>
        </div>
        <el-button type="danger" round  style="margin-right: 20px;" @click="search()">搜索</el-button>

      </div>
      <div >
        <div class="kflexc" style="margin-bottom: 20px;">

          <div style="background: #F3F5F8; border-radius: 20px; margin-right: 20px; padding-right: 20px;" class="kflexc ">
            <el-button type="danger" round style="margin-right: 20px;" @click="log2show"  v-if="checkquanxian('V020102').length > 0">导入结算订单</el-button>
            <div @click="xiazai" style=" font-size: 14px;  cursor: pointer; color: #333333;">下载模板</div>
          </div>
          <div class="ke2">
            <el-button type="danger" plain round style="margin-right: 20px;"@click="goid('/yongjinzhichu/zhichuguanli/daorubiao')">查看导入记录</el-button>
          </div>


          <div style="background: #F3F5F8; border-radius: 20px; margin-right: 20px; padding-right: 20px;" class="kflexc ">
            <el-upload ref="upload" action="#" :before-upload="uploasdx" :show-file-list="false" accept=".xlsx,.xls">
               <el-button type="danger" plain style="margin-right: 20px;" round>佣金补发导入</el-button>
            </el-upload>
            <div @click="xiazaix" style=" font-size: 14px;  cursor: pointer; color: #333333;">下载模板</div>
          </div>
          <div class="ke2">
            <el-button type="danger" plain round style="margin-right: 20px;"@click="goid('/yongjinzhichu/zhichuguanli/daorubiaox')">查看佣金补发导入记录</el-button>
          </div>



          <!-- <div @click="goid('/yongjinzhichu/zhichuguanli/daorubiao')" style="margin-right: 20px; font-size: 12px;  color: #409EFF; cursor: pointer;">查看导入记录</div> -->

          <el-button type="primary" plain round style="margin-right: 20px;" @click="daochu">导出待结算明细</el-button>
          <el-button type="primary" plain round style="margin-right: 20px;" @click="shanchuduo">批量删除</el-button>
          <el-button type="primary" plain round style="margin-right: 20px;" @click="xiugaiyongjinduo"  v-if="checkquanxian('V020101').length > 0">修改佣金金额</el-button>
        </div>


        <div style=" font-size: 14px;">
          <span style="margin-right: 10px; color: #555;">满足结算订单数:{{manzuall.fulfill_num}}</span>
          <span style="margin-right: 10px; color: #555;">满足结算金额:{{manzuall.fulfill_sum}}元</span>
          <span style="margin-right: 10px; color: #555;">不满足结算:{{manzuall.not_fulfill_num}}</span>
          <span style="margin-right: 10px; color: #555;">不满足结算金额:{{manzuall.not_fulfill_sum}}元</span>
          <span style="margin-right: 10px; color: #555;">不满足更改为满足结算:{{manzuall.change_not_fulfill_num}}</span>
          <span style="margin-right: 10px; color: rgb(12, 131, 255);">勾选的金额:{{jine}}元</span>
        </div>
      </div>

      <el-table :data="list" border style="width: 100%; margin: 20px 0;" ref="multipleTable" @select-all="handleSelectionChange" @selection-change="handleSelectionChange2">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column align='center' prop='order_id' label="订单ID"></el-table-column>
        <el-table-column align='center' prop='merchant_name' label="分销商名称"></el-table-column>
        <el-table-column align='center' prop='product_sku' label="商品名称"></el-table-column>
        <el-table-column align='center' prop='source_sku' label="商品编码"></el-table-column>
        <el-table-column align='center' prop='commission_income' label="佣金收入"></el-table-column>
        <el-table-column align='center' prop='ok' label="满足佣金结算">
          <template slot-scope="scope">
            <div v-if="scope.row.ok === ''"></div>
            <div v-if="scope.row.ok === 0">不满足</div>
            <div v-if="scope.row.ok === 1">满足</div>
          </template>
        </el-table-column>
        <el-table-column align='center' prop='commission' label="佣金支出">
          <template slot-scope="scope">
            <div>{{scope.row.commission}}</div>
            <div v-if="scope.row.commission_change_log">
              <el-tooltip class="item" effect="dark" :content="scope.row.commission_change_log + scope.row.remark" placement="top-start">
                <div style="color: #f00; cursor: pointer;">改</div>
              </el-tooltip>
            </div>

          </template>
        </el-table-column>
        <el-table-column align='center' prop='reissue_commission' label="补发金额"></el-table-column>
        <el-table-column align='center' prop='chuangjian' label="状态更新时间"></el-table-column>
        <el-table-column align='center' prop='status_updated_at' label="订单创建时间"></el-table-column>
        <el-table-column align='center' label="支出审核" v-if="peizhi.second_commission_examine && checkquanxian('V0204').length > 0">
          <template slot-scope="scope">
            <div v-if="scope.row.is_settlement === 0">不通过</div>
            <div v-if="scope.row.is_settlement === 1">通过</div>
          </template>
        </el-table-column>
        <el-table-column align='center' label="操作">
          <template slot-scope="scope">
            <div class="kflexc">
              <div style="color: #409EFF; margin: 10px; cursor: pointer;" @click="shanchu(scope.row)">删除</div>
              <div style="color: #409EFF; margin: 10px; cursor: pointer;" @click="yongjinguize(scope.row)">佣金规则</div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination style="text-align: right;" background :page-sizes="[20,100, 200, 300, 400]" @size-change="handleSizeChange" layout="sizes,total,prev, pager, next" :current-page="all.page" @current-change="fanye" :page-size="all.page_size" :total="total"></el-pagination>
    </div>

    <el-dialog title="导入待结算订单" center :visible.sync="log2" :close-on-click-modal="false" width="670px">
      <div>
        导入名称：
      </div>
      <el-input v-model="daoruall.log_name" placeholder="输入名称" style="margin-top: 10px;"></el-input>
      <div style="margin-top: 20px;">
        请选择触发结算方式：
      </div>
      <div style="border: 1px solid rgb(227, 228, 228); padding: 20px; margin-top: 20px;  cursor: pointer;" @click="daoruall.sum_type = 0" :style="{background:(daoruall.sum_type == 0?'rgb(236, 249, 255)':'')}">
        <div style="font-weight: bold;">按标准结算</div>
        <div>按照佣金规则计算支出金额，按订单激活状态计算支出金额(必须先完善激活状态)</div>
      </div>
      <div style="border: 1px solid rgb(227, 228, 228); padding: 20px; margin-top: 20px;  cursor: pointer;" @click="daoruall.sum_type = 1" :style="{background:(daoruall.sum_type == 1?'rgb(236, 249, 255)':'')}">
        <div style="font-weight: bold;">按简略结算</div>
        <div>按照导入表单触发待结算，金额将按照佣金规则设置的最小值结算(忽略激活状态)</div>
      </div>
      <div style="border: 1px solid rgb(227, 228, 228); padding: 20px; margin-top: 20px;  cursor: pointer;" @click="daoruall.sum_type = 2" :style="{background:(daoruall.sum_type == 2?'rgb(236, 249, 255)':'')}">
        <div style="font-weight: bold;">按粗放结算</div>
        <div>按照导入表触发结算，金额按照导入表的“结算金额"结算(导入多少就给结算多少）</div>
      </div>
      <div class="kflexc" style=" margin-top: 20px;">
        上传结算表单：
        <el-upload ref="upload" action="#" :before-upload="uploasd" :show-file-list="false" accept=".xlsx,.xls">
           <el-button type="primary" plain round>导入结算订单</el-button>
        </el-upload>
        <div style="margin-left: 20px;" v-if="daoruall.file">已上传文件</div>
        <div @click="xiazai" style="margin-left: 20px; font-size: 12px; color: #999; cursor: pointer; color: #1989FA;">下载模板</div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="info" round @click="log2 = false">取消</el-button>
        <el-button type="danger" round @click="daorugo">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="佣金规则" center :visible.sync="log" :close-on-click-modal="false" width="600px">
      <div v-if="guize.page_id != null" >
      	<span>佣金规则：{{guize.rules}} </span>
      	<span v-if="guize.active_commission != 0">已激活，佣金{{guize.active_commission}}元.</span>
      	<span v-if="guize.first_recharge_one_commission != 0">首充大于{{guize.first_recharge_one}}元，佣金{{guize.first_recharge_one_commission}}元</span>
      	<span v-if="guize.first_recharge_two_commission != 0">或者首充大于{{guize.first_recharge_two}}元，佣金{{guize.first_recharge_two_commission}}元.</span>
      	<span v-if="guize.recharge_amount_one_commission != 0">累计充值大于{{guize.recharge_amount_one}}元，佣金{{guize.recharge_amount_one_commission}}元</span>
      	<span v-if="guize.recharge_amount_two_commission != 0">且累计充值大于{{guize.recharge_amount_two}}元，佣金{{guize.recharge_amount_two_commission}}元.</span>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" round @click="log = false">关闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="修改佣金金额" center :visible.sync="logyongjin" :close-on-click-modal="false" width="600px">
      <div style="margin-bottom: 20px;">
      	<el-input v-model="xiugaiyongjinjine.commission" placeholder="金额"></el-input>
      </div>
      <div >
      	<el-input v-model="xiugaiyongjinjine.remark" placeholder="备注"></el-input>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" round @click="logyongjin = false">关闭</el-button>
        <el-button type="primary" round @click="yongjinqueding">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="多个订单ID搜索" :visible.sync="duoxuanlog" :close-on-click-modal="false" width="600px">
    	<div>
    		<el-input type="textarea" :rows="10" placeholder="一行一个，可直接粘贴excel纵列数据" v-model="duoxuanids"></el-input>
    	</div>
    	<div slot="footer" class="dialog-footer">
    		<el-button type="primary" size="small" @click="search2">搜索</el-button>
    	</div>
    </el-dialog>

    <el-dialog title="选择" :visible.sync="xuanzelog" :close-on-click-modal="false" width="500px">
      <div class="kflexc">
          <el-radio v-model="radio" :label="0">全选本页</el-radio>
          <el-radio v-model="radio" :label="1">全选全部</el-radio>
      </div>
      <div slot="footer" class="dialog-footer">
       <el-button round @click="xuanzelog = false">取消</el-button>
       <el-button type="danger" round @click="getcount">确定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="批量支出确认" :visible.sync="piliangzhichulog" :close-on-click-modal="false" width="500px">
      <div class="kflexc" style="color: rgb(64, 66, 71);">
          请再次点击确认本次支出，批量支出执行可能需要几分钟时间
      </div>
      <div slot="footer" class="dialog-footer">
       <el-button round @click="piliangzhichulog = false">取消</el-button>
       <el-button type="danger" round @click="piliangzhichugo">确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import top2 from './top.vue'
  import axios from 'axios'
  import top from '@/components/top.vue'
  import left from '@/components/left.vue'
  import foot from '@/components/foot.vue'
  import moment from "moment";
  import XLSX from 'xlsx';
  import {
      read,utils
    } from 'xlsx'

  export default {
    components: {
      "left": left,
      "top": top,
      "foot": foot,
      top2
    },
    name: "ke",
    data() {
      return {
        duoxuanids:"",
        duoxuanlog:false,
        dangqianxuanzhong:[],
        daoruall:{
          file:"",
          sum_type:0,
          log_name:""
        },
        log2:false,
        jine:0,
        times:[],
        loading:false,
        list:"",
        all:{
          order_ids:"",
          start:"",
          end:"",
          goods_name:"",
          order_id:"",
          merchant_name:"",
          cm_name:"",
          status:"",//未结算0,待结算10,已结算20,待打款30,已打款40 status
          page:1,
          page_size:20,
          change_type:"",
          ok:"",
          is_settlement:""
        },
        total:0,
        kehujinglilists:"",
        fenxiaoshanglists:"",
        log:false,
        guize:"",
        xiugaiyongjinjine:{
          commission:0,
          remark:""
        },
        logyongjin:false,
        manzuall:"",
        peizhi:"",
        zhichupeizhi:false,

        piliangzhichulog:false,
        xuanzelog:false,
        radio:0,
        dangqianxuanzhong2:[],
        daoruallx:""
      }
    },
    created() {
      this.getlist()


      // if(JSON.parse(localStorage.getItem('USER')).id == JSON.parse(localStorage.getItem('SHOP')).shop_id){
      //   this.zhichupeizhi = true
      // }

      // if(localStorage.getItem('shopConfigInfo')){
      //   this.peizhi = JSON.parse(localStorage.getItem('shopConfigInfo'))
      // }else{
      //   axios.get('/api/plan-market/expend/shopConfigInfo')
      //     .then(response => {
      //       if (response.data.msg.code == 0) {
      //         this.peizhi = response.data.data
      //         localStorage.setItem('shopConfigInfo',JSON.stringify(response.data.data))
      //       } else {
      //         this.$message.error(response.data.msg.info);
      //       }
      //   })
      // }




      //获取客户经理
      axios.get('/api/plan-market/user/userManagerList')
        .then(response => {
          if (response.data.msg.code == 0) {
             this.kehujinglilists = response.data.data
          } else {
             this.$message.error(response.data.msg.info);
          }
      })
      //获取全部分销商
      axios.get('/api/gth/partner/list?page_size=2000')
        .then(response => {
          if (response.data.msg.code == 0) {
            this.fenxiaoshanglists = response.data.data.data
          } else {
            this.$message.error(response.data.msg.info);
          }
        })

      axios.get('/api/plan-market/withdraw/amount/count')
        .then(response => {
          if (response.data.msg.code == 0) {
            this.manzuall = response.data.data
          } else {
            this.$message.error(response.data.msg.info);
          }
        })

      // axios.get('/api/plan-market/expend/shopConfigInfo')
      //   .then(response => {
      //     if (response.data.msg.code == 0) {
      //       this.peizhi = response.data.data

      //     } else {
      //       this.$message.error(response.data.msg.info);
      //     }
      // })


    },
    mounted() {

    },
    methods: {
      huoqupeizhi:function(item){
        this.peizhi = item
        console.log(this.peizhi)
      },
      search2: function() {
      	this.all.order_ids = this.duoxuanids.split(/\n/)
      	for (let i in this.all.order_ids) {
      		this.all.order_ids[i] = this.all.order_ids[i].trim()
      	}
        this.all.order_ids = this.all.order_ids.toString()
      	this.page = 1;
      	this.search();
      	this.duoxuanlog = false
      },
      log2show:function(){
        this.daoruall = {
          file:"",
          sum_type:0,
          log_name:""
        }
        this.log2 = true
      },

      uploasdx:function(file, fileList){
        let obj = new FormData()
        obj.append('file',file)
        axios.post('/api/plan-market/expend/reissue/imp',obj)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success(`导入成功`);
              this.log2 = false
              this.$router.push('/yongjinzhichu/zhichuguanli/daorubiaox')
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },

      uploasd(file, fileList) {
        this.daoruall.file = file
      },
      daorugo:function(){
        let obj = new FormData()
        obj.append('file',this.daoruall.file)
        obj.append('sum_type',this.daoruall.sum_type)
        obj.append('log_name',this.daoruall.log_name)
        axios.post('/api/plan-market/expend/imp',obj)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success(`导入成功`);
              this.getlist()
              this.log2 = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      //获取列表
      getlist: function() {
        axios.get('/api/plan-market/expend/orders',{params:this.all})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.list = response.data.data.data
              this.total = response.data.data.total
              this.loading = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      timeschange(){
        if(this.times && this.times.length > 0){
          this.all.start = this.times[0]
          this.all.end = this.times[1]
        }else{
          this.all.start = ''
          this.all.end = ''
        }
      },

      search: function() {
        this.all.page = 1
        this.getlist()
      },
      handleSizeChange: function(page) {
        this.loading = true
        this.all.page = 1
        this.all.page_size = page
        this.getlist()
      },

      //翻页
      fanye: function(page) {
        this.loading = true
        this.all.page = page
        this.getlist()
      },

      //下载模板
      xiazai: function() {
        const a = document.createElement('a');
        a.setAttribute('download', '导入支出订单.xlsx');
        a.setAttribute('href',location.origin + location.pathname + 'static/moban/zhichudaoru.xlsx');
        a.click();
      },
      xiazaix:function(){
        window.location.href = 'https://file.storep.91haoka.cn/yongjinbufa2.xlsx?attname='
      },

      xiugaiyongjinduo:function(){
        const selectedRows = this.$refs.multipleTable.selection;
        if (selectedRows.length === 0) {
          this.$message.warning('您还未选择任何数据，请先勾选数据后操作');
          return;
        }
        this.xiugaiyongjinjine = {
          commission:"",
          remark:""
        }
        this.logyongjin = true
      },

      getcount:function(){
        if(this.radio == 0){
            this.jine = 0
            console.log(this.dangqianxuanzhong)
            if(this.dangqianxuanzhong.length > 0){
              this.dangqianxuanzhong.forEach(item=>{
                if(item.ok == 1){
                  this.jine = parseFloat(item.commission) + this.jine
                }
              })
            }
        }
        if(this.radio == 1){
          axios.post('/api/plan-market/expend/orders/count',this.all)
            .then(response => {
              if (response.data.msg.code == 0) {
                this.jine = response.data.data.sum_commission
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        }
        this.xuanzelog = false
      },

      yongjinqueding:function(){
        if(this.radio == 0){
          axios.post('/api/plan-market/expend/order/change/commission',{ids:this.dangqianxuanzhong2,commission:this.xiugaiyongjinjine.commission,remark:this.xiugaiyongjinjine.remark})
            .then(response => {
              if (response.data.msg.code == 0) {
                this.$message.success('修改成功');
                this.logyongjin = false
                this.getlist()
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        }
        if(this.radio == 1){
          axios.post('/api/plan-market/expend/order/change/all/commission',{...this.all,commission:this.xiugaiyongjinjine.commission,remark:this.xiugaiyongjinjine.remark})
            .then(response => {
              if (response.data.msg.code == 0) {
                this.$message.success('修改成功');
                this.logyongjin = false
                this.getlist()
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        }

      },

      shanchuduo:function(){
        // 这边是获取选中的行数据
        const selectedRows = this.$refs.multipleTable.selection;
        if (selectedRows.length === 0) {
          this.$message.warning('您还未选择任何数据，请先勾选数据后操作');
          return;
        }
        if(this.radio == 0){
          this.$confirm('此操作将永久删除当前选中的订单, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            axios.post('/api/plan-market/expend/orders/del',{ids:this.dangqianxuanzhong2})
              .then(response => {
                if (response.data.msg.code == 0) {
                  this.$message.success('删除成功');
                  this.getlist()
                } else {
                  this.$message.error(response.data.msg.info);
                }
              })
          })
        }
        if(this.radio == 1){
          this.$confirm('此操作将永久删除全部的订单, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            axios.post('/api/plan-market/expend/orders/all/del',this.all)
              .then(response => {
                if (response.data.msg.code == 0) {
                  this.$message.success('删除成功');
                  this.getlist()
                } else {
                  this.$message.error(response.data.msg.info);
                }
              })
          })
        }
      },

      shanchu:function(item){
        this.$confirm('此操作将永久删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post('/api/plan-market/expend/order/del',{id:item.id})
            .then(response => {
              if (response.data.msg.code == 0) {
                this.$message.success('删除成功');
                this.getlist()
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        })
      },

      daochu:function(){
        let obj = {
          start:this.all.start,
          end:this.all.end,
          goods_name:this.all.goods_name,
          order_id:this.all.order_id,
          merchant_name:this.all.merchant_name,
          cm_name:this.all.cm_name,
          status:this.all.status,
          page:1,
          page_size:20,
          ids:this.dangqianxuanzhong,
          order_ids:this.all.order_ids,
          is_settlement:this.all.is_settlement,
          ok:this.all.ok,
          change_type:this.all.change_type
        }

        axios.post('/api/plan-market/expend/orders/exp',obj)
          .then(response => {
            if (response.data.msg.code == 0) {

              window.open(location.origin +'/gth/#/yongjinzhichu/daijiesuanjilu')
              // location.href = location.origin + '/' + response.data.data
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },

      yongjinguize:function(item){
        axios.get('/api/plan-market/commission/rule?config_id='+item.config_id)
        .then(response => {
          if (response.data.msg.code == 0) {
            this.guize = response.data.data
            this.log = true
          } else {
            this.$message.error(response.data.msg.info);
          }
        })
      },

      handleSelectionChange2:function(val){
        console.log(val)
        this.jine = 0
        this.dangqianxuanzhong = JSON.parse(JSON.stringify(val))
        if(this.dangqianxuanzhong.length > 0){
          this.dangqianxuanzhong.forEach(item=>{
            if(item.ok == 1){
              this.jine = parseFloat(item.commission) + this.jine
            }
            this.dangqianxuanzhong.push(item.id)
          })
        }


        if(val.length > 0){
          let arr = []
          val.forEach(item=>{
            arr.push(item.id)
          })
          this.dangqianxuanzhong2 = JSON.parse(JSON.stringify(arr))
        }else{
          this.dangqianxuanzhong2 = []
        }
      },
      handleSelectionChange(val) {
        this.dangqianxuanzhong = val
        if(val.length > 0){
          let arr = []
          val.forEach(item=>{
            arr.push(item.id)
          })
          this.dangqianxuanzhong2 = arr
          this.xuanzelog = true
        }else{
          this.dangqianxuanzhong2 = []
        }
      }

      // handleSelectionChange(val) {
      //   this.jine = 0
      //   this.dangqianxuanzhong = []
      //   if(val.length > 0){
      //     val.forEach(item=>{
      //       this.jine = parseFloat(item.commission) + this.jine
      //       this.dangqianxuanzhong.push(item.id)
      //     })
      //   }
      // }

    }
  }
</script>

<style lang="scss" scoped>
  .ke {
    /deep/ .ke2 .el-button--danger{ background: #FFF0F5; color: #2974FF;}
    .powertop {
    	display: flex;
    	background:#f9f9f9;
    }
    .powertopli {
    	flex-basis: 180px;
    	line-height: 50px;
    	border-bottom: 3px #F9F9F9 solid;
    	color: #727272;
    	border-right: 1px #F9F9F9 solid;
    	font-size: 16px;
    	text-align: center;
    }
    .router-link-active {
    	background: #FFFFFF;
    	border-bottom: 3px #2974FF solid;
    }
    /deep/ .el-pagination.is-background .btn-prev:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next:disabled{ background: rgba(246, 246, 246, 0.3); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .el-pagination.is-background .btn-next{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .btn-prev{ background: rgba(246, 246, 246,1); border: 1px rgba(167, 167, 167,1) solid;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active{ background-color: #2974FF;}
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled).active:hover {
        color: #fff;
    }
    /deep/ .el-pagination.is-background .el-pager li:not(.disabled):hover {
        color: #2974FF;
    }
    /deep/ .el-pager li{ border-radius: 14px; background: rgba(255, 255, 255, 1); border: 1px rgba(167, 167, 167, 0.3) solid;}
    /deep/ .btn-prev{ border-radius: 14px; padding: 0 10px;}
    /deep/ .btn-next{ border-radius: 14px; padding: 0 10px;}

    /deep/ .el-table th{ background: rgb(246, 246, 246);}
    /deep/ .el-input__inner{ line-height: 36px; height: 36px; font-size: 12px; background: rgb(247, 248, 250);  border: 0;}
    /deep/ .el-date-editor .el-range-input{ background: rgb(247, 248, 250); }
    /deep/ .el-button{ padding: 11px 23px !important;}
    /deep/ .el-button--mini{ padding: 6px 15px !important;}
    /deep/ .el-button--danger {
        color: #FFF;
        background-color: #2974FF;
        border-color: #2974FF;
    }
    .team {
    	background: #F9F9F9;
    }
  }
</style>
